Skip to content

feat(explore-suspect-attrs): Iterating on series data, sorting or dat… #95401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 14, 2025

Conversation

Abdkhan14
Copy link
Contributor

…a and tooltip

cohortsToSeriesData takes the cohorts and assigns a value of '0' to the chart series data if a label is not present in a cohort. Example: cohort1: {'prod': 1, 'local': 2} and cohort2: {'local': 3} -----> series_cohort_1: [{label: 'prod', value: '1'},{label: 'local', value: '2'}] and series_cohort_2: [{label: 'prod', value: '0'},{label: 'local', value: '3'}]

Note: Removed confining of tooltip, it will be cut off at the boundaries. Will set appendToBody:true (which pushes the tooltip up to document.body) along with the virtualization PR, otherwise the screen freezes trying to do it for too many charts.

@Abdkhan14 Abdkhan14 requested a review from a team as a code owner July 12, 2025 22:59
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jul 12, 2025
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Base automatically changed from abdk/explore-suspect-tags-chart-labels to master July 14, 2025 18:14
Comment on lines +43 to +44
const cohort1Map = new Map(cohort1.map(({label, value}) => [label, value]));
const cohort2Map = new Map(cohort2.map(({label, value}) => [label, value]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, is there a reason you used a map here instead of an object? It looks like your just using cohort1Map as a simple key value mapping and not taking advantage of the benefits of a map (like that it's iterable and ordered)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a residue from me initially thinking that we will need 'iterability', I'll use a record in a cleanup PR, soon

The functionality in this PR is under the flag
`performance-spans-suspect-attributes`:
- Virtualizes the list of charts
- Adds search
- Fixes tooltip (we couldn't append tooltip to `document.body` without
virtualization. It's too expensive, when we have hundreds of charts,
otherwise).

<img width="848" height="805" alt="Screenshot 2025-07-14 at 1 14 35 AM"
src="https://github.com/user-attachments/assets/74946b5e-c946-42bf-84c9-4bc406d700fe"
/>

---------

Co-authored-by: Abdullah Khan <abdullahkhan@PG9Y57YDXQ.local>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Chart Tooltips Show NaN% Due to Undefined Data

The valueFormatter function in Chart can cause "NaN%" to be displayed in tooltips. This occurs because the optional label parameter is used directly to access seriesTotals, potentially resulting in undefined and subsequent NaN in percentage calculations. Additionally, Number(seriesParams?.data) can convert an undefined data value to NaN, further contributing to incorrect percentages.

static/app/views/explore/components/suspectTags/charts.tsx#L153-L167

const valueFormatter = useCallback(
(_value: number, label?: string, seriesParams?: CallbackDataParams) => {
const data = Number(seriesParams?.data);
const total = seriesTotals[label as keyof typeof seriesTotals];
if (total === 0) {
return '\u2014';
}
const percentage = (data / total) * 100;
return `${percentage.toFixed(1)}%`;
},
[seriesTotals]
);

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

@Abdkhan14 Abdkhan14 merged commit f91f02d into master Jul 14, 2025
46 checks passed
@Abdkhan14 Abdkhan14 deleted the abdk/explore-sus-attrs-chart-sorting branch July 14, 2025 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants